

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'alerts_dialog_widget.dart';

/// @className : alert_dialog_widget_util
/// @date 2022/07/30 21:20 
/// @author : xiaohai
/// @description : 警告对话框工具类

class AlertsDialogWidgetUtil{

  /// 显示对话框
  /// context: 上下文
  /// titleStr: 标题
  /// canceEvent: 取消点击事件
  /// sureEvent: 确认点击事件
  void showAlertsDialogWidget(BuildContext context,String? titleStr,
      {Function()? canceEvent,Function()? sureEvent}) {

    showGeneralDialog(
        context: context,
        barrierDismissible: true,
        barrierLabel: '',
        transitionDuration: Duration(milliseconds: 200),
        transitionBuilder: (BuildContext context,
            Animation<double> animation,
            Animation<double> secondaryAnimation,
            Widget child) {
          return ScaleTransition(scale: animation, child: child);
        },
        pageBuilder: (BuildContext context, Animation<double> animation,
            Animation<double> secondaryAnimation) {
          return Dialog(
            backgroundColor: Colors.transparent,
            child: AlertsDialogWidget(titleStr:titleStr,canceEvent:canceEvent,sureEvent:sureEvent),
          );
        });
  }
}
